﻿using Kenly.DBFramework.TestModel.Purchasing;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Kenly.DBFramework.Gateway;
using System.Collections.Generic;

using System.Linq;

namespace Kenly.DBFramework.Tests
{


    /// <summary>
    ///这是 VendorTest 的测试类，旨在
    ///包含所有 VendorTest 单元测试
    ///</summary>
    [TestClass()]
    public class VendorTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///获取或设置测试上下文，上下文提供
        ///有关当前测试运行及其功能的信息。
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region 附加测试属性
        // 
        //编写测试时，还可使用以下属性:
        //
        //使用 ClassInitialize 在运行类中的第一个测试前先运行代码
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //使用 ClassCleanup 在运行完类中的所有测试后再运行代码
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //使用 TestInitialize 在运行每个测试前先运行代码
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //使用 TestCleanup 在运行完每个测试后运行代码
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        [TestMethod()]
        public void IsValidTest()
        {
            string msg = "Vendor.IsValid did not return the expected value.";

            Vendor target = new Vendor();

            Assert.IsFalse(target.IsValid, msg);

        }


        /// <summary>
        ///Validate 的测试
        ///</summary>
        //[TestMethod()]
        //public void ValidateTest()
        //{
        //    string msg = "Vendor.Validate did not return the expected value.";

        //    Vendor target = new Vendor();

        //    IEnumerable<RuleViolation> actual = target.Validate();
        //    if (actual != null)
        //    {
        //        IEnumerator<RuleViolation> enumerator = actual.GetEnumerator();
        //        while (enumerator.MoveNext())
        //        {
        //            bool hasValidated = (enumerator.Current.PropertyName == "AccountNumber") ||
        //                (enumerator.Current.PropertyName == "Name");

        //            Assert.IsTrue(hasValidated, msg);
        //        }
        //    }
        //}

        //[TestMethod()]
        //public void ValidateOutRuleViolationTest()
        //{
        //    string msg = "Vendor.Validate(out violations) did not return the expected value.";

        //    Vendor target = new Vendor();
        //    List<RuleViolation> violations;

        //    bool actual = target.Validate(out violations);

        //    Assert.IsFalse(actual, msg);
        //    Assert.IsTrue(violations.Exists(p => (p.PropertyName == "AccountNumber") ||
        //            (p.PropertyName == "Name")), msg);
        //}
    }
}
